package com.aduerr.v1shouyin.mvp.activity;

import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.view.View;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import com.aduerr.v1shouyin.R;
import com.aduerr.v1shouyin.util.SharedPreferencesUtils;

public class ShiftDutyActivity extends AppCompatActivity {

    @BindView(R.id.img_back)
    ImageView imgBack;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.tv_right)
    TextView tvRight;
    @BindView(R.id.rl_title)
    RelativeLayout rlTitle;
    @BindView(R.id.cb_has_shiftduty)
    CheckBox cbHasShiftduty;
    @BindView(R.id.tv_has_duty)
    TextView tvHasDuty;
    @BindView(R.id.cb_no_shiftduty)
    CheckBox cbNoShiftduty;
    @BindView(R.id.tv_no_duty)
    TextView tvNoDuty;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shift_duty);
        ButterKnife.bind(this);
        tvTitle.setText("交接班模式");
        Boolean hasShiftDuty = (Boolean) SharedPreferencesUtils.getParam(this,
                "hasShiftDuty", true);
        if(hasShiftDuty) {
            cbHasShiftduty.setChecked(true);
            cbNoShiftduty.setChecked(false);
        } else {
            cbHasShiftduty.setChecked(false);
            cbNoShiftduty.setChecked(true);
        }

    }

    @OnClick({R.id.img_back, R.id.cb_has_shiftduty, R.id.cb_no_shiftduty})
    public void onViewClicked(View view) {
        switch(view.getId()) {
            case R.id.img_back:
                finish();
                break;
            case R.id.cb_has_shiftduty:
                cbHasShiftduty.setChecked(true);
                cbNoShiftduty.setChecked(false);
                SharedPreferencesUtils.setParam(this, "hasShiftDuty", true);//默认是有交接班的
                break;
            case R.id.cb_no_shiftduty:
                cbHasShiftduty.setChecked(false);
                cbNoShiftduty.setChecked(true);
                SharedPreferencesUtils.setParam(this, "hasShiftDuty", false);
                break;
        }
    }
}
